package com.oj.system.manager;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.oj.common.core.constants.CacheConstants;
import com.oj.common.core.enums.ResultCode;
import com.oj.common.redis.service.RedisService;
import com.oj.common.security.exception.ServiceExpection;
import com.oj.system.domain.question.Question;
import com.oj.system.mapper.QuestionMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * @Description
 * @Author bin
 * @Date 2025/6/24
 */
@Component
public class QuestionCacheManager {

    @Resource
    private RedisService redisService;

    public void addCache(Long questionId) {
        //现在创建的题目一定是所有题目最晚的 所以排在第一个 头插
        redisService.leftPushForList(CacheConstants.QUESTION_LIST, questionId);
    }

    public void deleteCache(Long questionId) {
        // redis中维护的题目顺序表
        redisService.removeForList(CacheConstants.QUESTION_LIST, questionId);
    }
}
